export function getAssets(url) {
  return new URL(url, import.meta.url).href
}

export function tree2TableData(tree, dataKey = 'id', labelKey = 'label') {
  const nodes = []
  for (let i = 0; i < tree.length; i++) {
    const item = tree[i]
    const node = {
      key: item[dataKey],
      label: item[labelKey],
      data: item,
    }

    nodes.push(node)
    if (item.children && item.children.length > 0) {
      node.children = tree2TableData(item.children, dataKey, labelKey)
    }
  }
  return nodes
}
